

#include "string.h"

using namespace WtfEngine;

#ifdef __UNICODE__

String::~String() {
	if(msCString) delete msCString;
};

const char * String::c_str() const {
	std::string s(*this); // This is discarded - we use the intermediate UTF8 buffer
	return msCString;
};

String::operator std::string () const {
	if(msCString) delete msCString;

	// Ugly conversion, hopefully this won't happen too often.
	this->msCString = new char[length() + 1];
	extract(0, length(), msCString);

	return std::string(msCString);
};

#endif
